package com.ruoyi.project.zerocarbon.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.zerocarbon.domain.DeclareExternalOrganization;
import com.ruoyi.project.zerocarbon.service.IDeclareExternalOrganizationService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 外部支持机构团队信息Controller
 * 
 * @author ruoyi
 * @date 2022-03-13
 */
@RestController
@RequestMapping("/zerocarbon/organization")
public class DeclareExternalOrganizationController extends BaseController
{
    @Autowired
    private IDeclareExternalOrganizationService declareExternalOrganizationService;

    /**
     * 查询外部支持机构团队信息列表
     */
    @PreAuthorize("@ss.hasPermi('zerocarbon:organization:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeclareExternalOrganization declareExternalOrganization)
    {
        startPage();
        List<DeclareExternalOrganization> list = declareExternalOrganizationService.selectDeclareExternalOrganizationList(declareExternalOrganization);
        return getDataTable(list);
    }

    /**
     * 导出外部支持机构团队信息列表
     */
    @PreAuthorize("@ss.hasPermi('zerocarbon:organization:export')")
    @Log(title = "外部支持机构团队信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(DeclareExternalOrganization declareExternalOrganization)
    {
        List<DeclareExternalOrganization> list = declareExternalOrganizationService.selectDeclareExternalOrganizationList(declareExternalOrganization);
        ExcelUtil<DeclareExternalOrganization> util = new ExcelUtil<DeclareExternalOrganization>(DeclareExternalOrganization.class);
        return util.exportExcel(list, "外部支持机构团队信息数据");
    }

    /**
     * 获取外部支持机构团队信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('zerocarbon:organization:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(declareExternalOrganizationService.selectDeclareExternalOrganizationById(id));
    }

    /**
     * 新增外部支持机构团队信息
     */
    @PreAuthorize("@ss.hasPermi('zerocarbon:organization:add')")
    @Log(title = "外部支持机构团队信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeclareExternalOrganization declareExternalOrganization)
    {
        return toAjax(declareExternalOrganizationService.insertDeclareExternalOrganization(declareExternalOrganization));
    }

    /**
     * 修改外部支持机构团队信息
     */
    @PreAuthorize("@ss.hasPermi('zerocarbon:organization:edit')")
    @Log(title = "外部支持机构团队信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeclareExternalOrganization declareExternalOrganization)
    {
        return toAjax(declareExternalOrganizationService.updateDeclareExternalOrganization(declareExternalOrganization));
    }

    /**
     * 删除外部支持机构团队信息
     */
    @PreAuthorize("@ss.hasPermi('zerocarbon:organization:remove')")
    @Log(title = "外部支持机构团队信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(declareExternalOrganizationService.deleteDeclareExternalOrganizationByIds(ids));
    }
}
